<div class="subrow">
        <div class="subcol1"></div>
        <div class="subcol2">
            <img src="images/bank/method_qq.jpg" width="533" height="114" alt="">
        </div>
        <div class="clear"></div>
    </div>
    
    <form id="subpagetp_online_form" method="post" onsubmit="return false;" target="_blank" action="#">
        <div class="subrow">
            <div class="subcol1">充值金额：</div>
            <div class="subcol2">
                <input id="onlinePayAmount" name="amount" autocomplete="off" type="text" class="textfield1"> 
                <span class="validation">
                    <img src="images/iconwarning.jpg" width="17" height="15" alt=""> 
                    <span class="smalltxt red">请输入充值金额，
                        最低金额<i class="config_min_rech_money">0</i>&nbsp;&nbsp;
                        最高金额<i class="config_max_rech_money">00</i>
                    </span>
                </span>
            </div>
            <div class="clear"></div>
        </div>
        <div class="subrow">
            <div class="subcol1">在线渠道：</div>
            <div class="subcol2" id="onlinie-banks">
                
            </div>
            <div class="clear"></div> 
        </div>
        <div class="subrow remark-subrow" style="display: none">
            <div class="subcol1"> </div>
            <div class="subcol2 blue">
                <span>温馨提示：</span>
                <span class="remark-text"></span>
            </div>
            <div class="clear"></div>
        </div>
        <div class="subrow margintop10">
            <div class="subcol1"> </div>
            <div class="subcol2">
                <input type="submit" class="c-button" value="开始充值" id="start-charge">
            </div>
            <div class="clear"></div>
        </div>
    </form>

    <form method="post" action="" target="_blank" style="display:none" id="form-hidden">
    </form>
    
    <script>
        var template = '<div class="banklist marginbtm10" style="line-height:35px; min-width: 120px;">\
                    <input type="radio" name="payId" value="__v__" chargeType="__type__" class="bankradiobtn" style="margin:10px 5px 0px 3px;">\
                    <span style="padding-right: 8px;">__n__</span>\
                </div>';
        
        var banks = [];
        context.center.chargeType = "online";
        ME.query(function() {
            var grade = context.user.user.layer || 0;
            grade = grade + '';
            CMD.pay_uquery(function(r) {
                for (var i in r.list) {
                    var data = r.list[i];
                    data.layer = data.layer.split(",");
                    if (data.enable != 1 || data.payType != 'qq') continue;
                    if (data.layer.indexOf(grade) == -1) continue;
                    banks.push(data);
                }
                banks.sort(function(a, b) {
                    return (b.sort || 0) - (a.sort || 0);
                });
    
                // 填充充值列表
                for (var i in banks) {
                    var d = banks[i];
                    var l = template.replace(/__v__/, d.mchId);
                    l = l.replace(/__type__/, d.type);
                    l = l.replace(/__n__/, d.name);
                    $("#onlinie-banks").append(l);
                }
                $("#onlinie-banks input")[0].checked = true;
    
                // 最高金额、最低金额
                $(".config_min_rech_money").html(getSelectBankInfo().min);
                $(".config_max_rech_money").html(getSelectBankInfo().max);

                $(".banklist span").click(function(e) {
                    var input = $(e.currentTarget).parent().find("input")[0];
                    if (!input.checked) input.checked= true;
                });

                $(".banklist input").change(function() {
                    $(".config_min_rech_money").html(getSelectBankInfo().min);
                    $(".config_max_rech_money").html(getSelectBankInfo().max);
                })
            });
        });
    
        $("#start-charge").click(function() {
            var d = getSelectBankInfo();
            var amount = $("#onlinePayAmount").val().trim();
            if (!amount) {
                alert2("请输入存款金额", true);
                return;
            }
            amount = parseInt(amount);
            if (amount < parseInt(d.min)) {
                alert2('存款金额至少' + d.min + '元', true);
                return;
            }
            if (amount > parseInt(d.max)) {
                alert2('存款金额超过' + d.max + '元', true);
                return;
            }
                    
            // 提交充值
            if (d.type == 'heyifuu') {
                // 合易付
                var url = Util.genUrl({
                    file: "heyifuu.html",
                    key: d.key,
                    amount: amount,
                    payType: 6,
                });
                window.open(url);

                layer.open({
                    type : 2,
                    title : '订单信息',
                    scrollbar : false,
                    closeBtn : 1,
                    shade : [ 0.5 ],
                    area : [ '340px', '260px' ],
                    content : "pages/center/charge/pay_bank_online_window.html"
                });
                $(".layui-layer iframe").css("height", "228px");
            }
            else if (d.type == 'sslsf') {
                // 闪付
                var url = Util.genUrl({
                    file: "sslsf.html",
                    key: d.key,
                    amount: amount,
                    payType: 77,
                    payUrl: encodeURIComponent(d.payUrl),
                });
                window.open(url);

                layer.open({
                    type : 2,
                    title : '订单信息',
                    scrollbar : false,
                    closeBtn : 1,
                    shade : [ 0.5 ],
                    area : [ '340px', '260px' ],
                    content : "pages/center/charge/pay_bank_online_window.html"
                });
                $(".layui-layer iframe").css("height", "228px");
            }
            else if (d.type == 'xinmapay') {
                // 新码
                var url = Util.genUrl({
                    file: "xinmapay.html",
                    key: d.key,
                    amount: amount,
                    payType: 50,
                    source: "qr",
                });
                window.open(url);

                layer.open({
                    type : 2,
                    title : '订单信息',
                    scrollbar : false,
                    closeBtn : 1,
                    shade : [ 0.5 ],
                    area : [ '340px', '260px' ],
                    content : "pages/center/charge/pay_bank_online_window.html"
                });
                $(".layui-layer iframe").css("height", "228px");
            }
        });
    
        // 取得使用的充值方式信息
        function getSelectBankInfo() {
            var v = $("input:radio:checked").attr("value");
            for (var i in banks) {
                if (banks[i].mchId == v) return banks[i];
            }
        }

        // 获取充值金额
        function _getChargeAmount() {
            return $("#onlinePayAmount").val().trim();
        }

        // 查看充值记录
        function _seeChargeDetail() {
            context.center.menu = 'charge_log';
            switch_page("center/money", $(".content-wrap"));
        }
    </script>